package com.source.multithread.xml;

/**
 * @Author wengqy
 * @Date 2021/1/8
 */
import java.io.IOException;
import java.io.StringReader;
import java.io.StringWriter;
/*
 * 修改日期:2020/04/05
 * 修改人:牟松
 * 字符流StringReader和StringWriter基本操作练习
 */
public class StringWriterReadDemo {
    public static void main(String[] args)
    {
        //用法跟byteArrayInputStream和byteArrayOutputStream的用法差不多
        StringReader reader = new StringReader("i love you时间的话");
        StringWriter writer = new StringWriter();
        int length;
        try {
            while((length = reader.read())!=-1)
            {
                int chUpper = Character.toUpperCase(length);
                System.out.println(length);
                writer.write(chUpper);
            }
            System.out.println(writer.getBuffer().toString());
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
